# central registry:中央登记中心
from flask import Flask,request
from flask import render_template
from reserch import reserch4letters
app = Flask(__name__)
# 1.相对路径，决定了页面资源的路径，如果没有登记，将返回404

@app.route('/',methods=['GET'])
def hello_world():  # put application's code here
    return render_template('<h1>hello.html</h1>')

@app.route('/index',methods=['GET'])
def hello_world():  # put application's code here
    return render_template('index.html')

#【POST】实现用户输入，点击提交，将数据提交到/result
@app.route('/result',methods=['POST'])
def result():
    #接受数据：request.form[HTML-参数名称]
    #1.完整的应用：用户输入数据----->后端接收数据--->处理数据---->返回到HTML页面
    #2.元音字母查询（第二个功能）
    #3.自选： 购物车或者课表
    py_firstname = request.form['firstname']
    py_lastname = request.form['lastname']
    py_fullname = py_firstname.title()+''+py_lastname.title()
    py_vowels = request.form['vowels']
    py_word = request.form['word']
    py_found = {}
    for i in py_word:
        if i in py_word:
            py_found.setdefault(i,0)
            py_found[i] +=1
    return render_template('result.html',
                           fullname = py_fullname)

if __name__ == '__main__':
    app.run(host='127.0.0.1',port=5000,debug=True)
